var app = getApp(),
  $ = require("../../utils/httpHelper.js")
Page({
  data: {
    about_info: {},
    shareHidden: true
  },
  onShareAppMessage: function (res) {
    app.shareApp(res)
  },
  onLoad: function (options) {
      $.httpPost("about", {}, (data, err) => {
        this.setData({
          about_info:data.data.about
        })
      })
  },
  //登记按钮弹框
  showinfoDialog() {
    this.setData({
      shareHidden: false
    })
  },
  hiddenShare() {
    this.setData({
      shareHidden: true
    })
  },

  //分享按钮提交表单
  formSubmit: function (e) {
    if (!app.check_empty(e.detail.value.username) && !app.check_empty(e.detail.value.userphone) && !app.check_empty(e.detail.value.usertoy)) {
      if (app.checkPhone(e.detail.value.userphone)) {
        var rd_session = wx.getStorageSync('rd_session');
        var param = { rd_session: rd_session, name: e.detail.value.username, phone: e.detail.value.userphone, good_name: e.detail.value.usertoy }
        $.httpPost("applay_refund", param, (data, err) => {
          wx.showToast({
            title: data.message,
            duration: 2000
          })
          this.setData({
            shareHidden: true
          })
        })
      }else{
        wx.showToast({
          title: '手机格式不对哦！~',
          duration: 2000
        })
      }
      
    } else {
      wx.showToast({
        title: '有信息没有填写哦~',
        duration: 2000
      })
    }

    console.log('form发生了submit事件，携带数据为：', e.detail.value)
  },
  formReset: function () {
    this.setData({
      shareHidden: true
    })
    console.log('form发生了reset事件')
  },
  callphone(e) {
    let num = e.currentTarget.dataset.num
    wx.makePhoneCall({
      phoneNumber: num
    })
  },
  
});